<template>
    <div>
    <el-dialog
        title="设备参数设置"
        :visible.sync="dialogVisible"
        width="70%">
        <p><b>控制盒序号:  {{this.equipExtend.outerCode}}</b></p>

        <el-table :data="tableData" border style="width: 100%">
            <el-table-column label="序号" type="index" width="45"></el-table-column>
            <el-table-column prop="names" label="属性名称" width="180"></el-table-column>
            <el-table-column prop="svalue" label="属性值" width="180"></el-table-column>
            <el-table-column prop="describes" label="属性说明"></el-table-column>
            <el-table-column prop="address" label="操作" width="223">
                <template slot-scope="scope">
                    <el-link type="primary" :underline="false" @click="handleClick(scope.row)" v-if="hasPermission('equip:equipExtend:edit')"
                    >设置</el-link>
                </template>
            </el-table-column>
        </el-table>

        <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
        </span>

    </el-dialog>
        <div>
            <set-param ref="setParam" @refreshDataList="getList"></set-param>
        </div>
    </div>

</template>

<script>
import {extendList} from '@/api/equipment/management.js'
import setParam from '@/views/modules/equipment/setParam'
export default {
    data () {
        return {
            dialogVisible: false,
            tableData: [],
            equipExtend: {
                outerCode: '', // 控制盒序号,
                equipId: '',
                equipInnerCode: ''
            }
        }
    },
    components: {
        setParam
    },
    methods: {
        init (row, method) {
            this.dialogVisible = true
            this.equipExtend.outerCode = row.outerCode
            this.equipExtend.equipId = row.id
            this.equipExtend.equipInnerCode = row.innerCode
            this.getList()
        },
        // 获取参数列表
        getList () {
            extendList({otherUse: 3}).then(res => {
                if (res.data.code === '200') {
                    this.tableData = res.data.result.list
                    this.total = res.data.result.count
                }
            })
        },
        // 设置参数
        handleClick (row) {
            this.$refs.setParam.init(row, this.equipExtend)
        }
    }
}
</script>

<style lang="scss" scoped>
p{
    margin-bottom: 10px;
}
</style>
